package com.onlyxiahui.common.action.description.handler.impl.title;

import java.lang.reflect.Method;

import com.onlyxiahui.common.action.description.DocumentContext;
import com.onlyxiahui.common.action.description.annotation.DocTitle;
import com.onlyxiahui.common.action.description.bean.ModuleData;
import com.onlyxiahui.common.action.description.handler.MethodTitleHandler;

/**
 * Description <br>
 * Date 2020-01-08 08:46:54<br>
 * 
 * @author XiaHui [onlovexiahui@qq.com]<br>
 * @since 1.0.0
 */

public class MethodSetTitleHandler implements MethodTitleHandler {

	@Override
	public boolean support(DocumentContext context, ModuleData moduleData, Method method, String text) {
		boolean hasTitle = null != method.getAnnotation(DocTitle.class);
		return hasTitle;
	}

	@Override
	public String handle(DocumentContext context, ModuleData moduleData, Method method, String text) {
		DocTitle md = method.getAnnotation(DocTitle.class);
		return md.value();
	}
}
